package lock;

import org.junit.Test;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.*;

/**
 * @describe: 类描述信息
 * @author: morningcat.zhang
 * @date: 2019/4/22 4:33 PM
 */
public class LockTest {

    @Test
    public void test1() {
        Lock lock = new ReentrantLock();

        Lock lock2 = new ReentrantLock(true);
    }

    @Test
    public void test2() {
        ReadWriteLock readWriteLock = new ReentrantReadWriteLock();

        ReadWriteLock readWriteLock2 = new ReentrantReadWriteLock(true);
    }

    @Test
    public void test3() {
        Lock readLock = new Lock() {
            @Override
            public void lock() {

            }

            @Override
            public void lockInterruptibly() throws InterruptedException {

            }

            @Override
            public boolean tryLock() {
                return false;
            }

            @Override
            public boolean tryLock(long time, TimeUnit unit) throws InterruptedException {
                return false;
            }

            @Override
            public void unlock() {

            }

            @Override
            public Condition newCondition() {
                return null;
            }
        };
    }
}
